#include <stdio.h>
#include <stdlib.h>

int main() {
    int m, count;
    scanf("%d %d", &m, &count);

    int *arr = (int *)malloc(m * sizeof(int));

    for (int i = 0; i < m; i++) {
        scanf("%d", &arr[i]);
    }

    for (int i = 0; i < count; i++) {
        int start, end, score;
        scanf("%d %d %d", &start, &end, &score);
        for (int j = start - 1; j <= end - 1; j++)
            arr[j] = arr[j] + score;
    }

    int min = arr[0];
    for (int i = 1; i < m; i++) {
        if (arr[i] < min)
            min = arr[i];
    }

    printf("%d", min);

    free(arr); // 释放动态数组的内存
    return 0;
}
